﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Menu_Topmaster : System.Web.UI.Page
{
    int i = 1;
    public int j = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataSet DS = new DataSet();
            DS.ReadXml(Server.MapPath("~/App_Data/Menu2.xml"));
            ParentRepeater.DataSource = DS;
            ParentRepeater.DataBind();
        }
    }

    protected void ParentRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {

        RepeaterItem item = e.Item;
        if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
        {
            Repeater ChildRepeater = (Repeater)item.FindControl("ChildRepeater");
            ChildRepeater.ItemDataBound += new RepeaterItemEventHandler(ChildRepeater_ItemDataBound);
            DataRowView drv = (DataRowView)item.DataItem;
            DataView dview = drv.CreateChildView("Menu_SubMenu");
            dview.Sort = "text";

            ChildRepeater.DataSource = dview;// here u can also bind the Child Repeater with DataTable like 
            //ChildRepeater.DataSource = datatableName;
            ChildRepeater.DataBind();
        }
    }

    protected void ChildRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            HyperLink hlnk = (HyperLink)e.Item.FindControl("hy1");
            hlnk.Attributes["rel"] = "anylinkmenu" + (i++);
        }
    }
}
